import { request } from '../utils/request.js'
// 获取文章列表
export const listArticle = params => request({
  method: 'GET',
  url: '/v1_0/mp/articles',
  params
})

// 删除文章
export const deleteArticle = target => request({
  method: 'DELETE',
  url: `/v1_0/mp/articles/${target}`
})

// 获取文章详细内容
export const getArticle = id => request({
  method: 'GET',
  url: `/v1_0/mp/articles/${id}`
})

// 上传图片
// export const uploadImg = function () {
//   return 'http://geek.itheima.net/v1_0/upload'
// }

// 发布文章
export const publishArticle = (draft, data) => request({
  method: 'POST',
  url: '/v1_0/mp/articles',
  data,
  params: { draft: draft }
})
// 编辑文章
export const editArticle = (id, draft, data) => request({
  method: 'PUT',
  url: `/v1_0/mp/articles/${id}`,
  data,
  params: { draft: draft }
})
